}
}
-static char*
-escape_for_xmessage (const char *str)
-{
- GString *retval;
- const char *p;
-
- retval = g_string_new (NULL);
-
- p = str;
- while (*p)
- {
- switch (*p)
- {
- case ' ':
- case '"':
- case '\\':
- g_string_append_c (retval, '\\');
- break;
- }
-
- g_string_append_c (retval, *p);
- ++p;
- }
-
- return g_string_free (retval, FALSE);
-}
-
static void
broadcast_xmessage (GdkDisplay *display,
const char *message_type,
Atom type_atom_begin;
Window xwindow;
+ if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
+ return;
+
{
XSetWindowAttributes attrs;
XFlush (xdisplay);
}
+/**
+ * gdk_x11_display_broadcast_startup_message:
+ * @display: a #GdkDisplay
+ * @message_type: startup notification message type ("new", "change",
+ * or "remove")
+ * @...: a list of key/value pairs (as strings), terminated by a
+ * %NULL key. (A %NULL value for a key will cause that key to be
+ * skipped in the output.)
+ *
+ * Sends a startup notification message of type @message_type to
+ * @display.
+ *
+ * This is a convenience function for use by code that implements the
+ * freedesktop startup notification specification. Applications should
+ * not normally need to call it directly. See the <ulink
+ * url="http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt">Startup
+ * Notification Protocol specification</ulink> for
+ * definitions of the message types and keys that can be used.
+ *
+ * Since: 2.12
+ **/
+void
+gdk_x11_display_broadcast_startup_message (GdkDisplay *display,
+ const char *message_type,
+ ...)
+{
+ GString *message;
+ va_list ap;
+ const char *key, *value, *p;
+
+ message = g_string_new (message_type);
+ g_string_append_c (message, ':');
+
+ va_start (ap, message_type);
+ while ((key = va_arg (ap, const char *)))
+ {
+ value = va_arg (ap, const char *);
+ if (!value)
+ continue;
+
+ g_string_append_printf (message, " %s=\"", key);
+ for (p = value; *p; p++)
+ {
+ switch (*p)
+ {
+ case ' ':
+ case '"':
+ case '\\':
+ g_string_append_c (message, '\\');
+ break;
+ }
+
+ g_string_append_c (message, *p);
+ }
+ g_string_append_c (message, '\"');
+ }
+ va_end (ap);
+
+ broadcast_xmessage (display,
+ "_NET_STARTUP_INFO",
+ "_NET_STARTUP_INFO_BEGIN",
+ message->str);
+
+ g_string_free (message, TRUE);
+}
+
/**
* gdk_notify_startup_complete:
*
{
GdkDisplay *display;
GdkDisplayX11 *display_x11;
- gchar *escaped_id;
- gchar *message;
display = gdk_display_get_default ();
if (!display)
if (display_x11->startup_notification_id == NULL)
return;
- if (!G_LIKELY (display_x11->trusted_client))
- return;
-
gdk_notify_startup_complete_with_id (display_x11->startup_notification_id);
}
gdk_notify_startup_complete_with_id (const gchar* startup_id)
{
GdkDisplay *display;
- gchar *escaped_id;
- gchar *message;
display = gdk_display_get_default ();
if (!display)
return;
- escaped_id = escape_for_xmessage (startup_id);
- message = g_strdup_printf ("remove: ID=%s", escaped_id);
- g_free (escaped_id);
-
- broadcast_xmessage (display,
- "_NET_STARTUP_INFO",
- "_NET_STARTUP_INFO_BEGIN",
- message);
-
- g_free (message);
+ gdk_x11_display_broadcast_startup_message (display, "remove",
+ "ID", startup_id,
+ NULL);
}
/**